package com.ruoyi.web.controller.driver;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.driver.domain.TDriverBindVehicleRecords;
import com.ruoyi.driver.service.ITDriverBindVehicleRecordsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 司机绑定车辆记录Controller
 * 
 * @author ruoyi
 * @date 2024-12-27
 */
@RestController
@RequestMapping("/driver/records")
public class TDriverBindVehicleRecordsController extends BaseController
{
    @Autowired
    private ITDriverBindVehicleRecordsService tDriverBindVehicleRecordsService;

    /**
     * 查询司机绑定车辆记录列表
     */
    @PreAuthorize("@ss.hasPermi('driver:records:list')")
    @GetMapping("/list")
    public TableDataInfo list(TDriverBindVehicleRecords tDriverBindVehicleRecords)
    {
        startPage();
        List<TDriverBindVehicleRecords> list = tDriverBindVehicleRecordsService.selectTDriverBindVehicleRecordsList(tDriverBindVehicleRecords);
        return getDataTable(list);
    }

    /**
     * 导出司机绑定车辆记录列表
     */
    @PreAuthorize("@ss.hasPermi('driver:records:export')")
    @Log(title = "司机绑定车辆记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TDriverBindVehicleRecords tDriverBindVehicleRecords)
    {
        List<TDriverBindVehicleRecords> list = tDriverBindVehicleRecordsService.selectTDriverBindVehicleRecordsList(tDriverBindVehicleRecords);
        ExcelUtil<TDriverBindVehicleRecords> util = new ExcelUtil<TDriverBindVehicleRecords>(TDriverBindVehicleRecords.class);
        util.exportExcel(response, list, "司机绑定车辆记录数据");
    }

    /**
     * 获取司机绑定车辆记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('driver:records:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(tDriverBindVehicleRecordsService.selectTDriverBindVehicleRecordsById(id));
    }

    /**
     * 新增司机绑定车辆记录
     */
    @PreAuthorize("@ss.hasPermi('driver:records:add')")
    @Log(title = "司机绑定车辆记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TDriverBindVehicleRecords tDriverBindVehicleRecords)
    {
        return toAjax(tDriverBindVehicleRecordsService.insertTDriverBindVehicleRecords(tDriverBindVehicleRecords));
    }

    /**
     * 修改司机绑定车辆记录
     */
    @PreAuthorize("@ss.hasPermi('driver:records:edit')")
    @Log(title = "司机绑定车辆记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TDriverBindVehicleRecords tDriverBindVehicleRecords)
    {
        return toAjax(tDriverBindVehicleRecordsService.updateTDriverBindVehicleRecords(tDriverBindVehicleRecords));
    }

    /**
     * 删除司机绑定车辆记录
     */
    @PreAuthorize("@ss.hasPermi('driver:records:remove')")
    @Log(title = "司机绑定车辆记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(tDriverBindVehicleRecordsService.deleteTDriverBindVehicleRecordsByIds(ids));
    }
}
